const Koa = require('koa');
const Router = require('koa-router');
const app = new Koa();
const router = new Router();

router.get('/api', (ctx, next) => {
    console.log(`${ctx.method} ${ctx.url}`);
    console.log(ctx.router);
    ctx.body = `${ctx.method} ${ctx.url}`;
});

app
  .use(router.routes())
  .use(router.allowedMethods());

app.listen(3000, () => {
    console.log(' koa server start!');
});